
#include <ctime>
#include <iostream>
#include <fstream>

using namespace std;
void bS(int list[], int listLength){
     while (listLength--){
            bool swapped = false;

     for(int i = 0; i < listLength; i++) {
            if(list[i] > list[i + 1]){
                    swap(list[i], list[i + 1]);
            swapped = true;
            }
     }
     if(swapped == false) break;
}
}

 void r_f_f(const char *filename, int a[], int length) {
    ifstream file(filename);
    for(int i=0; i < length; i++)
        file >> a[i];
}
int main ()
{
    #define LEN 5000
    int a [LEN] ;

    r_f_f("ml_sorted.txt", a, LEN);
    unsigned int start = clock();
    bS (a, LEN) ;
    unsigned int finish = clock();
    unsigned int work=finish-start;
    cout<<"ml_sorted.txt " << work << " milliseconds \n";

    r_f_f ("m2_reverse.txt" , a, LEN) ;
    start = clock();
    bS (a, LEN) ;
    finish = clock();
    work=finish-start;
    cout<<"m2_reverse.txt " << work << " milliseconds \n";

    r_f_f("m3_shuffle.txt" , a, LEN);
    start = clock();
    bS (a, LEN) ;
    finish = clock();
    work=finish-start;
    cout<<"m3_shuffle.txt " << work << " milliseconds \n";
    return 0;
}
